
function doLogout(){
	dojo.xhrPost({
		url: "/service/doLogout",
		handleAs: "text",
		handle: function(data,args){
			if(data=="ok"){
				window.location.reload();
			}
			else{
				alert("error:"+data);
			}
		}
	});
}

function doLogin(){
	dojo.xhrPost({
		url: '/service/doLogin',
		handleAs: 'json',
		handle: function(data,args){
			if(data.message == "success"){
				showMain(data.nickName);
			}else{
				errMsg="Wrong name or password, Login again ,please!<br>"
				dojo.byId("errMsg2").innerHTML = errMsg;
			}
		},
		form: 'login'
	 });
}

function doDispatcher(){
	dojo.xhrPost({
		url: "/service/doDispatcher",
		handleAs: "json",
		handle: function(data,args){
			if(data.target=="init"){
				showInit();
			}
			else if(data.target=="login"){
				showLogin();
			}
			else if(data.target=="main"){
				user = new selfpass.module.User(
						data.name, data.password, data.nickName);
				showMain();
			}
			else{
				alert("error:"+data);
			}
		}
	});
}
